<template>
    <div>
        <el-dialog title="收货地址" :visible.sync="myDialog.flag" width="800px">
            <el-form :model="roleAdd">
                <el-form-item label="角色名称" label-width="80px">
                    <el-input v-model="roleAdd.roleName" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="角色描述" label-width="80px">
                    <el-input v-model="roleAdd.roleDesc" autocomplete="off"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="myDialog.flag = false">取 消</el-button>
                <el-button type="primary" @click="submit()">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import roleAdd from '@/utils/roleApi/roleAddApi'
import roleEdit from '@/utils/roleApi/roleEditApi'
export default {
    props:{
        myDialog:Object,
        roleAdd:Object,
        editId:Number
    },
    data() {
        return {
           
        }
    },
    methods:{
        async submit() {
            if(this.myDialog.type == 'add') {
                /* 请求添加角色接口 */
                let res = await roleAdd(this.roleAdd);
                if (res.meta.status == 201) {
                    this.$message.success(res.meta.msg);
                    this.close();
                    this.$emit('getRoleList');
                }
            } else if (this.myDialog.type == 'edit') {
                /* 情趣编辑角色接口 */
                let res = await roleEdit(this.editId,this.roleAdd);
                if(res.meta.status == 200) {
                    this.$message.success(res.meta.msg);
                    this.close();
                    this.$emit('getRoleList');
                }
            }
        },
        close() {
            this.myDialog.flag = false;
        }
    },
    mounted() {

    }
}
</script>

<style lang="scss" scoped>

</style>